package com.yang.lesson05;

import javax.swing.*;
import java.awt.*;

public class JFrameDemo extends JFrame {

    public JFrameDemo()  {
        Container container = getContentPane();//"getContentPane"

        container.setLayout(new GridLayout(2,1,20,20));//后面的参数时间距的意思

        JPanel panel1 = new JPanel(new GridLayout(1,3));
        JPanel panel2 = new JPanel(new GridLayout(2,1));
        JPanel panel3 = new JPanel(new GridLayout(1,3));
        JPanel panel4 = new JPanel(new GridLayout(2,3));

        panel1.add(new Button("1"));
        panel1.add(new Button("1"));
        panel1.add(new Button("1"));
        panel2.add(new Button("2"));
        panel2.add(new Button("2"));
        panel3.add(new Button("3"));
        panel3.add(new Button("3"));
        panel3.add(new Button("3"));
        panel4.add(new Button("4"));
        panel4.add(new Button("4"));
        panel4.add(new Button("4"));
        panel4.add(new Button("4"));
        panel4.add(new Button("4"));
        panel4.add(new Button("4"));

        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setSize(600,600);

        container.add(panel1);
        container.add(panel2);
        container.add(panel3);
        container.add(panel4);

    }

    public static void main(String[] args) {
        new JFrameDemo();
    }
}
